package com.anjubao.parking.municipal.parkinglot.util;

import com.anjubao.parking.municipal.common.utils.BeanUtils;
import com.anjubao.parking.municipal.parkinglot.dto.DeviceLogDto;
import com.anjubao.parking.municipal.parkinglot.dto.ParkingLotGeomagneticStatusDto;
import com.anjubao.parking.municipal.parkinglot.dto.VideoPileDto;
import com.anjubao.parking.municipal.parkinglot.form.ParkingGeomagneticForm;
import com.anjubao.parking.municipal.parkinglot.model.ParkingLotDeviceGeomagneticSensor;
import com.anjubao.parking.municipal.parkinglot.model.ParkingLotDeviceStatus;

public class FormTransfer {
    /**
     * 封装地磁信息
     * @param parkingLot
     * @param parkingGeomagneticForm
     * @return
     */
    public static ParkingLotDeviceGeomagneticSensor from2ParkingGeomagnetic(ParkingLotGeomagneticStatusDto parkingLot, ParkingGeomagneticForm parkingGeomagneticForm){
        ParkingLotDeviceGeomagneticSensor geomagneticSensor = BeanUtils.transform(ParkingLotDeviceGeomagneticSensor.class, parkingLot);
        geomagneticSensor.setParkingLotDistrictId(parkingGeomagneticForm.getParkingLotDistrictId());
        geomagneticSensor.setParkingLotCode(parkingGeomagneticForm.getParkingLotCode());
        geomagneticSensor.setParkingLotSlotCode(parkingGeomagneticForm.getParkingLotSlotCode());
        geomagneticSensor.setMachineNo(parkingGeomagneticForm.getMachineNo());
        geomagneticSensor.setName(parkingGeomagneticForm.getName());
        return geomagneticSensor;
    }

    public static ParkingLotDeviceStatus from2ParkingLotDeviceStatus(ParkingLotGeomagneticStatusDto parkingLotGeomagneticStatusDto , ParkingLotDeviceGeomagneticSensor parkingGeomagnetic){
        ParkingLotDeviceStatus parkingLotDeviceStatus = BeanUtils.transform(ParkingLotDeviceStatus.class, parkingGeomagnetic);
        parkingLotDeviceStatus.setDeviceId(parkingGeomagnetic.getId());
        parkingLotDeviceStatus.setDeviceCode(parkingGeomagnetic.getCode());
        parkingLotDeviceStatus.setDeviceName(parkingGeomagnetic.getName());
        parkingLotDeviceStatus.setDeviceType(3);
        parkingLotDeviceStatus.setProvinceId(parkingGeomagnetic.getParkingLotProvinceId());
        parkingLotDeviceStatus.setProvinceName(parkingGeomagnetic.getParkingLotProvinceName());
        parkingLotDeviceStatus.setCityId(parkingGeomagnetic.getParkingLotCityId());
        parkingLotDeviceStatus.setCityName(parkingGeomagnetic.getParkingLotCityName());
        parkingLotDeviceStatus.setDistrictId(parkingGeomagnetic.getParkingLotDistrictId());
        parkingLotDeviceStatus.setDistrictName(parkingGeomagnetic.getParkingLotDistrictName());
        parkingLotDeviceStatus.setIsOnline(0);
        parkingLotDeviceStatus.setStatus(0);
        parkingLotDeviceStatus.setRemainingBattery(0);
        parkingLotDeviceStatus.setLocation(parkingLotGeomagneticStatusDto.getLocation());
        return parkingLotDeviceStatus;
    }

    /**
     * 封装设备log冗余信息
     * @param deviceLogDto
     * @param videoPileDto
     * @return
     */
    public static DeviceLogDto from2ParkingLotDeviceLog(DeviceLogDto deviceLogDto, VideoPileDto videoPileDto){
        deviceLogDto.setParkingLotProvinceId(videoPileDto.getParkingLotProvinceId());
        deviceLogDto.setParkingLotProvinceName(videoPileDto.getParkingLotProvinceName());
        deviceLogDto.setParkingLotCityId(videoPileDto.getParkingLotCityId());
        deviceLogDto.setParkingLotCityName(videoPileDto.getParkingLotCityName());
        deviceLogDto.setParkingLotDistrictId(videoPileDto.getParkingLotDistrictId());
        deviceLogDto.setParkingLotDistrictName(videoPileDto.getParkingLotDistrictName());
        deviceLogDto.setParkingLotName(videoPileDto.getParkingLotName());
        deviceLogDto.setParkingLotId(videoPileDto.getParkingLotId());
        deviceLogDto.setParkingLotCode(videoPileDto.getParkingLotCode());
        return deviceLogDto;
    }

}
